<extend name="Layout/ins_page" />
<block name="content">
	<div class="page-header clearfix">
		<div class="dropdown col-sm-8">			
			<b class="dropdown-toggle" data-toggle="dropdown"><span class="title">全部</span><span class="fa fa-caret-down"></span></b>
			<ul class="dropdown-menu">
				<li gid="">
					<a>全部</a>
				</li>
				<foreach name="tag_list" item="vo">
					<li gid="{$key}">
						<a>{$vo}</a>
					</li>
				</foreach>
			</ul>
		</div>
		<div class="col-sm-4 pull-right">
			<div class="search_box col-20 pull-right">
				<div class="input-group ">
					<input type="hidden" value="abc" >
					<input  class="form-control" type="text"  name="keyword" id="keyword" onkeydown="key_local_search();"/>
					<div class="input-group-btn">
						<a class="btn btn-sm btn-info" onclick="btn_local_search();"><i class="fa fa-search" ></i> </a>
					</div>
				</div>
			</div>
		</div>
	</div>
	<foreach name="tag_list" item="tag">
		<assign name="var" value="$key" />
		<div class="ibox float-e-margins" gid="{$key}">
			<div class="ibox-title">
				<h5 class="smaller">{$tag}</h5>
			</div>
			<div class="ibox-content clearfix">
				<div class="space-8"></div>
				<foreach name="list" item="vo">
					<eq name="var" value="$vo.tag">
						<div class="col-sm-3 col-xs-6 text-center">
							<a class="btn btn-info btn-block" href="{:U('add','type='.$vo['id'])}">{$vo.name}</a>
							<div class="space-8"></div>
						</div>
					</eq>
				</foreach>
			</div>
		</div>
	</foreach>
</block>
<block name="js">
	<script type="text/javascript">
		function key_local_search() {
			if (event.keyCode == 13) {
				$(".ibox div.col-sm-3").hide();
				val = $("#keyword").val().toUpperCase();
				if (val.length == 0) {
					$(".page-header .title").html("全部");
				} else {
					$(".page-header .title").html("搜索结果");
				}				
				count = 0;
				$(".ibox a.btn").each(function() {
					if ($(this).text().indexOf(val) >= 0) {
						count++;
						$(this).parent().show();
					};
				});
			}
		}

		function btn_local_search() {
			console.log("y");
			$(".ibox div.col-sm-3").hide();
			val = $("#keyword").val().toUpperCase();
			if (val.length == 0) {
				$(".page-header .title").html("全部");
			} else {
				$(".page-header .title").html("搜索结果");
			}
			count = 0;
			$(".ibox a.btn").each(function() {
				if ($(this).text().indexOf(val) >= 0) {
					count++;
					$(this).parent().show();
				};
			});
		}

		$(document).ready(function() {
			set_return_url();
			$(".page-header .dropdown-menu li").click(function() {
				$(".ibox").hide();
				gid = $(this).attr("gid");
				$(".title").html($(this).text());
				count = 0;
				$(".ibox").each(function() {
					if ($(this).attr("gid").indexOf(gid) >= 0) {
						count++;
						$(this).show();
					};
				});
			});
		});
	</script>
</block>
